package com.atguigu.spzx.cloud.order.controller;

import com.alibaba.fastjson.JSON;
import com.atguigu.spzx.cloud.feign.api.client.UserClient;
import com.atguigu.spzx.cloud.model.entity.Order;
import com.atguigu.spzx.cloud.model.entity.User;
import com.atguigu.spzx.cloud.order.service.OrderService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Map;

// com.atguigu.spzx.cloud.order.controller
@RestController
@RequestMapping(value = "/api/order")
public class OrderController {

    @Autowired
    private OrderService orderService ;

    @Resource
    UserClient userClient;
    @GetMapping(value = "/testParam")
    public String testParam(){
        userClient.test1("zhangsan","suzhou");
        User user = new User();
        user.setUserName("lisi");
        user.setAddress("hangzhou");
        userClient.test2(user);

        user.setUserName("wangwu");
        userClient.test3(JSON.parseObject(JSON.toJSONString(user), Map.class));

        userClient.test4(Arrays.asList(1,2,3,4,5,6));
        user.setUserName("pangliu");
        userClient.test5(user);

        return "SUCCESS";
    }


    @GetMapping(value = "/findOrderByOrderId/{orderId}")
    public Order findOrderByOrderId(@PathVariable("orderId") Long orderId) {
        return orderService.findOrderByOrderId(orderId) ;
    }

}